/// <reference path="../types.ts" />
/// <reference path="../helpers.ts" />
/// <reference path="organization.ts" />

module $Xrm.Messages {
    export class WhoAmIRequest extends OrganizationRequest {
        constructor() {
            super("WhoAmI", "b");
        }

        GetResponse(responseXml: Document): WhoAmIResponse {
            return new WhoAmIResponse(responseXml);
        }

        ToSoapXml(): string {
            return super.ToSoapXml();
        }
    }

    export class WhoAmIResponse extends OrganizationResponse {
        public UserId: string;
        public BusinessUnitId: string;
        public OrganizationId: string;

        constructor(responseXml?: Document) {
            super("WhoAmI", responseXml);

            this.BindProperties();
        }

        BindProperties(): void {
            super.BindProperties();

            this.UserId = this.Results["UserId"];
            this.BusinessUnitId = this.Results["BusinessUnitId"];
            this.OrganizationId = this.Results["OrganizationId"];
        }
    }
}